package com.srv.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public abstract class DAOGenerico {

	private java.sql.Connection connection;

	protected java.sql.Connection getConnection() {
		return this.connection;
	}

	protected DAOGenerico() throws ClassNotFoundException, SQLException {
		Class.forName("com.mysql.jdbc.Driver");

		String location = "localhost";
		String port = "3306";
		String database = "srv";

		String user = "root";
		String password = "super";
		this.connection = DriverManager.getConnection("jdbc:mysql://"
				+ location + ":" + port + "/" + database, user, password);
	}

	protected ResultSet getResultSet(String query) throws SQLException {
		Connection connection = this.getConnection();
		Statement st = connection.createStatement();
		return st.executeQuery(query);
	}

}
